<template>
    <div id="section">
        <div v-if="noMedicalRecord" class="nomedrecord">
          <p style="height:90px;line-height:90px;font-size: 14px;font-weight: bold;color: gray;">您还没有病例可查看</p>
          <img src="../../assets/medical.png" alt="" width="200px">
          <p class="next" @click="addMedical">新增病例</p>
        </div>
      <div v-else style="padding-top: 20px;">
        <div class="card" v-for="item in MedicalRecord">
          <p class="titlep">
            <span class="title">病历资料</span>
            <span style="font-size: 14px;font-weight: bold;color: rgba(0, 146, 252, 0.5);" @click="dieaseDetial(item)">详情</span>
          </p>
          <p class="row" style="margin-top: 10px;">
            <span class="titletxt">基础状况：</span>
            <span >{{item.Weight}}kg</span>
          </p>
          <p class="row">
            <span class="titletxt">癌症名称：</span>
            <span >{{item.TumorName}}</span>
          </p>
          <p class="row">
            <span class="titletxt">确诊时间：</span>
            <span >{{setNum(item.DiagnosticTime)}}</span>
          </p>
          <p class="row">
            <span class="titletxt">大脑状态：</span>
            <span >{{item.BrainCondition}}</span>
          </p>
          <p class="row">
            <span class="titletxt">家族史：</span>
            <span>{{item.FamilyHistory}}</span>
          </p>
          <p class="textarea" style="padding-bottom: 20px;">
            <span class="titletxt" style=" color: gray;">体力状况：</span>
            <span class="textarea">{{item.PhysicalCondition}}</span>
          </p>
        </div>
        <p class="add" @click="addMedical" v-if="ifHide">新增病例</p>
      </div>
    </div>
</template>
<script>
  import {Indicator  } from "mint-ui";
  import {getCaseList} from "../../api/api"
export default {
    data(){
        return{
            ifHide:false,
            noMedicalRecord:false,
            MedicalRecord:[
                ],
        }
    },
    methods:{
          addMedical(){
            this.$router.push({
              path:'/addBaseInfo'
            })
          },
      //详情
      dieaseDetial(item){
        localStorage.setItem("RecordId",item.Id);
        this.$router.push(
            {
              name:'病历详情',
              params:{item:item}
            });
      },
      getCaseList(){
        Indicator.open({
          spinnerType: 'fading-circle'
        });
        getCaseList(localStorage.getItem("choosePatientId")).then(res=>{
            Indicator.close();
            this.ifHide=true;
            this.MedicalRecord=res.data.Result;
          if(this.MedicalRecord.length>0){
            this.noMedicalRecord=false;
          }
          else{
            console.log("没有病历");
            this.noMedicalRecord=true;
          }
        });
      },
      setNum(item) {
        if (item) {
          return item.slice(0, 10);
        }
      }
    },
  mounted() {
        document.getElementById("section").style.minHeight=localStorage.getItem("windowHeight")+"px";
        this.getCaseList();
  },
}
</script>
<style lang="scss" scoped>
  #section{
    background-color: rgba(220, 220, 220, 0.2);
  }
  .nomedrecord{
    height: 500px;
    line-height: 300px;
  }
  .next{
    width: 90%;
    height: 40px;
    position: fixed;
    bottom:40px;
    left:5%;
    border-radius: 5px;
    color: white;
    text-align: center;
    line-height: 45px;
    letter-spacing: 3px;
    background-color: rgba(0, 146, 252, 0.5);
  }
  .add{
    width: 90%;
    height: 40px;
    margin: 0 auto;
    border-radius: 5px;
    color: white;
    text-align: center;
    line-height: 45px;
    letter-spacing: 3px;
    margin-top: 50px;
    background-color: rgba(0, 146, 252, 0.5);
  }
  .card{
    width: 90%;
    margin: 0 auto;
    border-radius: 5px;
    background-color: white;
    margin-bottom: 30px;
    .titlep{
      width: 90%;
      height:40px;
      margin: 0 auto;
      border-bottom: 1px solid rgba(0, 0, 0, 0.1);
      span{
        display: inline-block;
        width: 100px;
        height:40px;
        line-height: 40px;
        float: right;
        text-align: right;
      }
      .title{
        float:left;
        text-align: left;
      }
    }
    .title:before{
      content:"";
      display: inline-block;
      width: 3px;
      height: 15px;
      background-color: rgba(0, 146, 252, 0.5);
      vertical-align: middle;
      margin-right: 5px;
      border-radius: 5px;
    }
    .row{
      width: 90%;
      height: 25px;
      margin: 0 auto;
      text-align: left;
      span{
        font-size: 13px;
        display: inline-block;
        line-height: 25px;
      }
      .titletxt{
        width: 80px;
        color: gray;
      }
    }
    .textarea{
      display: flex;
      width: 90%;
      margin: 0 auto;
      .titletxt{
        width: 106px !important;
        text-align: left;
      }
      span{
        font-size: 13px;
        line-height: 25px;
        text-align:left;
      }
    }
  }
</style>

